import { createWorker } from 'tesseract.js'

const worker = await createWorker("eng", 1, {
  corePath: '../../node_modules/tesseract.js-core',
  workerPath: "../../node_modules/tesseract.js/dist/worker.min.js",
  logger: function(m){console.log(m);}
});

await worker.load();  // 加载
await worker.loadLanguage('eng');  // 加载英文的语言包
await worker.initialize('eng');  // 加载

export const recognize = async function(base64Image: string) {
  const ret = await worker.recognize(base64Image)
  console.log(ret.data.text)
  return ret.data.text
}